package com.fesine.quartz.chapter14;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

import java.util.Date;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2016/11/20 19:58
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/11/20 19:58
 */
public class Listing_14_1 {
    Log logger = LogFactory.getLog(Listing_14_1.class);

    public static void main(String[] args) {
        new Listing_14_1().run();
    }

    public void run() {
        try {
            Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
            JobDetail detail = new JobDetail("firstJob", null, FirstJob.class);
            JobListener listener = new JobChainListener(SecondJob.class, "chainJobListener");
            //scheduler.addJobListener(listener);
            //detail.addJobListener(listener.getName());
            Trigger trigger = TriggerUtils.makeImmediateTrigger(0, 5000);
            trigger.setName("firstJobTrigger");
            trigger.setStartTime(new Date());
            scheduler.scheduleJob(detail, trigger);
            scheduler.start();
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
}
